﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace caculate
{
    public partial class NormalMode : Form
    {
        public NormalMode()
        {
            InitializeComponent();
            label1.Text = Exc.NormalQuestions[1]+"=";
            label2.Text = Exc.NormalQuestions[2] + "=";
            label3.Text = Exc.NormalQuestions[3] + "=";
            label4.Text = Exc.NormalQuestions[4] + "=";
            label5.Text = Exc.NormalQuestions[5] + "=";
            label6.Text = Exc.NormalQuestions[6] + "=";
            label7.Text = Exc.NormalQuestions[7] + "=";
            label8.Text = Exc.NormalQuestions[8] + "=";
            label9.Text = Exc.NormalQuestions[9] + "=";
            label10.Text = Exc.NormalQuestions[10] + "=";
            label11.Text = Exc.NormalQuestions[11] + "=";
            label12.Text = Exc.NormalQuestions[12] + "=";
            label13.Text = Exc.NormalQuestions[13] + "=";
            label14.Text = Exc.NormalQuestions[14] + "=";
            label15.Text = Exc.NormalQuestions[15] + "=";
            label16.Text = Exc.NormalQuestions[16] + "=";
            label17.Text = Exc.NormalQuestions[17] + "=";
            label18.Text = Exc.NormalQuestions[18] + "=";
            label19.Text = Exc.NormalQuestions[19] + "=";
            label20.Text = Exc.NormalQuestions[20] + "=";
            Exc.NormalAnswer2 = new int[21];
            int i;
            for (i = 1; i <= 20; i++)
            {
                Exc.NormalAnswer2[i] = -2;
            }
        }

        private void NormalMode_Load(object sender, EventArgs e)
        {
            TEMP.ischanged = 0;
        }

        public class TEMP
        {
            public static int ischanged = 0;
        }

        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox1.Text, @"^[0-9]+$") )
            {
                //为数字
                Exc.NormalAnswer2[1] = int.Parse(textBox1.Text);
            }
            else
            {
                textBox1.Text="";

                if(TEMP.ischanged==0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示","警告");
                    TEMP.ischanged = 1;
                }            
            }
            //Judge.judge_and_answer(1, textBox1.Text);
            //Exc.NormalAnswer2[1] = int.Parse(textBox1.Text);
        }

        private void TextBox2_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox2.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[2] = int.Parse(textBox2.Text);
            }
            else
            {
                textBox2.Text = "";
                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[2] = int.Parse(textBox2.Text);
        }

        private void TextBox3_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox3.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[3] = int.Parse(textBox3.Text);
            }
            else
            {
                textBox3.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
           // Exc.NormalAnswer2[3] = int.Parse(textBox3.Text);
        }

        private void TextBox4_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox4.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[4] = int.Parse(textBox4.Text);
            }
            else
            {
                textBox4.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
           // Exc.NormalAnswer2[4] = int.Parse(textBox4.Text);
        }

        private void TextBox5_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox5.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[5] = int.Parse(textBox5.Text);
            }
            else
            {
                textBox5.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[5] = int.Parse(textBox5.Text);
        }

        private void TextBox6_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox6.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[6] = int.Parse(textBox6.Text);
            }
            else
            {
                textBox6.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[6] = int.Parse(textBox6.Text);
        }

        private void TextBox7_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox7.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[7] = int.Parse(textBox7.Text);
            }
            else
            {
                textBox7.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[7] = int.Parse(textBox7.Text);
        }

        private void TextBox8_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox8.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[8] = int.Parse(textBox8.Text);
            }
            else
            {
                textBox8.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[8] = int.Parse(textBox8.Text);
        }

        private void TextBox9_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox9.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[9] = int.Parse(textBox9.Text);
            }
            else
            {
                textBox9.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[9] = int.Parse(textBox9.Text);
        }

        private void TextBox10_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox10.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[10] = int.Parse(textBox10.Text);
            }
            else
            {
                textBox10.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[10] = int.Parse(textBox10.Text);
        }

        private void TextBox11_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox11.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[11] = int.Parse(textBox11.Text);
            }
            else
            {
                textBox11.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[11] = int.Parse(textBox11.Text);
        }

        private void TextBox12_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox12.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[12] = int.Parse(textBox12.Text);
            }
            else
            {
                textBox12.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[12] = int.Parse(textBox12.Text);
        }

        private void TextBox13_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox13.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[13] = int.Parse(textBox13.Text);
            }
            else
            {
                textBox13.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[13] = int.Parse(textBox13.Text);
        }

        private void TextBox14_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox14.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[14] = int.Parse(textBox14.Text);
            }
            else
            {
                textBox14.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
           // Exc.NormalAnswer2[14] = int.Parse(textBox14.Text);
        }

        private void TextBox15_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox15.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[15] = int.Parse(textBox15.Text);
            }
            else
            {
                textBox15.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
           // Exc.NormalAnswer2[15] = int.Parse(textBox15.Text);
        }

        private void TextBox16_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox16.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[16] = int.Parse(textBox16.Text);
            }
            else
            {
                textBox16.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[16] = int.Parse(textBox16.Text);
        }

        private void TextBox17_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox17.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[17] = int.Parse(textBox17.Text);
            }
            else
            {
                textBox17.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[17] = int.Parse(textBox17.Text);
        }

        private void TextBox18_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox18.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[18] = int.Parse(textBox18.Text);
            }
            else
            {
                textBox18.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
           // Exc.NormalAnswer2[18] = int.Parse(textBox18.Text);
        }

        private void TextBox19_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox19.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[19] = int.Parse(textBox19.Text);
            }
            else
            {
                textBox19.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[19] = int.Parse(textBox19.Text);
        }

        private void TextBox20_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(textBox20.Text, @"^[0-9]+$"))
            {
                //为数字
                Exc.NormalAnswer2[20] = int.Parse(textBox20.Text);
            }
            else
            {
                textBox20.Text = "";

                if (TEMP.ischanged == 0)
                {
                    MessageBox.Show("必须输入正整数，非法输入将不予显示", "警告");
                    TEMP.ischanged = 1;
                }
            }
            //Exc.NormalAnswer2[20] = int.Parse(textBox20.Text);
        }
    }
}
